package IPrototipo.Funcionalidades.ABMCompetencia;

import IPrototipo.Funcionalidades.Menues.FrameUsuarioAutenticado;
import IPrototipo.Funcionalidades.Menues.iDialogGeneral;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.JScrollPane;
import javax.swing.JEditorPane;
import javax.swing.border.TitledBorder;

public class iReglamento extends iDialogGeneral {

	private static final long serialVersionUID = 1L;
	private final JPanel contentPanel = new JPanel();
	private JEditorPane editorPane;
	private String reglamento;




	public iReglamento(FrameUsuarioAutenticado perteneciente, boolean modal) {
		
		super(perteneciente,modal);
		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		Dimension tam= new Dimension(400, 280);
		setTamanio(tam);
		
		getContentPane().setLayout(new BorderLayout());
		{
			JPanel panelTitulo = new JPanel();
			getContentPane().add(panelTitulo, BorderLayout.NORTH);
			{
				JLabel lblTitulo = new JLabel("Ingreso de Reglamento");
				lblTitulo.setFont(new Font("Vani", Font.PLAIN, 20));
				panelTitulo.add(lblTitulo);
			}
		}
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
		{
			JPanel panelDelScroll = new JPanel();
			contentPanel.add(panelDelScroll);
			{
				JScrollPane scrollPane = new JScrollPane();
				scrollPane.setBorder(new TitledBorder(null, "Reglamento", TitledBorder.LEADING, TitledBorder.TOP, null, null));
				panelDelScroll.add(scrollPane);
				scrollPane.setMaximumSize(new Dimension(320,130));
				scrollPane.setPreferredSize(new Dimension(320, 130));
				scrollPane.scrollRectToVisible(getBounds());
				{
					editorPane = new JEditorPane();
					if(reglamento!=null){ editorPane.setText(reglamento);}
					scrollPane.setViewportView(editorPane);
				}
			}
		}

		{
			JPanel buttonPane = new JPanel();
			buttonPane.setMaximumSize(panel);
			buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton okButton = new JButton("Aceptar");
				okButton.setActionCommand("OK");
				buttonPane.add(okButton);
				okButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { 
					setReglamento(editorPane.getText());
					getParent().setFocusable(true);
					dispose();
					}
				});
								
			}
			{
				Component horizontalStrut = Box.createHorizontalStrut(20);
				buttonPane.add(horizontalStrut);
			}
			{
				JButton cancelButton = new JButton("Cancelar");
				cancelButton.setActionCommand("Cancel");
				buttonPane.add(cancelButton);
				cancelButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { 
					getParent().setFocusable(true);
					dispose();
					}
				});
						
			}
		}
	}

	
	
	public String getReglamento() {
		String ret= editorPane.getText();
		return ret;
	}



	public void setReglamento(String reglamento) {
		this.reglamento = reglamento;
	}

	
	

}
